﻿package bacIns 
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import game.events.EventData;
	import game.VolumeController;
	/**
	 * ...
	 * @author ... Doan Nguyen Thuy Nha Truc (Bamboo)	
	 */
	public class VolumeController extends MovieClip
	{
		public var icon:MovieClip;
		public var volume:game.VolumeController;
		public function VolumeController() 
		{
			this.hide();
			this.addEventListener(MouseEvent.ROLL_OUT, rollOutHdl);
			this.icon.addEventListener(MouseEvent.ROLL_OVER, rollOverHdl);
			this.icon.addEventListener(MouseEvent.CLICK,hdlSoundClick)
		}
		private function hdlSoundClick(e:MouseEvent):void {
			
			if (this.icon.currentLabel == "play") {
					this.icon.gotoAndStop("stop");	
					dispatchEvent(new EventData(EventData.LOCK_VOLUME_GAME, true));
				} else {
					this.icon.gotoAndStop("play");	
					dispatchEvent(new EventData(EventData.UN_LOCK_VOLUME_GAME, true));
				}
		}
		public function hide():void {
			if(this.volume.visible)
				this.volume.visible = false;
			
		}
		
		public function show():void {
			if(!this.volume.visible)
				this.volume.visible =  true;
			
		}
		
		private function rollOutHdl(e:MouseEvent):void 
		{
			this.hide();
		}
		
		private function rollOverHdl(e:MouseEvent):void 
		{
			this.show();
		}
	}

}